//
//  PhotosViewController.m
//  WonderfulNotes
//
//  Created by 千锋 on 16/1/16.
//  Copyright © 2016年 andy. All rights reserved.
//

#import "PhotosViewController.h"
#import "MLSelectPhotoAssets.h"
#import "MLSelectPhotoPickerBrowserPhoto.h"
#import "MLSelectPhotoPickerAssetsViewController.h"

@interface PhotosViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@end

@implementation PhotosViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
   // self.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.1];
    self.imageView.image = [MLSelectPhotoPickerViewController getImageWithImageObj:self.assets[self.index]];
    
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)preBtnClicked:(UIButton *)sender {
    
    self.index--;
    if (self.index<0) {
        
        self.index = self.assets.count-1;
    }
    
    self.imageView.image = [MLSelectPhotoPickerViewController getImageWithImageObj:self.assets[self.index]];
    
    //创建核心动画
    CATransition * animation = [CATransition animation];
    
    animation.type = @"cube";
    animation.subtype = kCATransitionFromRight;
    animation.duration = 1;
    
    [self.imageView.layer addAnimation:animation forKey:nil];

}

- (IBAction)nextBtnClicked:(UIButton *)sender {
    
    self.index++;
    if (self.index>self.assets.count-1) {
        self.index=0;
    }
    
    self.imageView.image = [MLSelectPhotoPickerViewController getImageWithImageObj:self.assets[self.index]];
    
    //创建核心动画
    CATransition * animation = [CATransition animation];
    
    animation.type = @"cube";
    animation.subtype = kCATransitionFromLeft;
    animation.duration = 1;
    
    [self.imageView.layer addAnimation:animation forKey:nil];

}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
